package cn.itcast.mybatis.demo3.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import cn.itcast.mybatis.demo3.UserDao;
import cn.itcast.mybatis.pojo.User;

public class UserDaoImpl implements UserDao {

	private SqlSession sqlSession;
	
	
	 public UserDaoImpl(SqlSession sqlSession) {
		this.sqlSession = sqlSession;
	}
	
	
	@Override
	public User getUserById(int id) {
		User user = sqlSession.selectOne("getUserById", id);
		sqlSession.close();
		return user;
	}


	@Override
	public List<User> getUserByAddress(String string) {
		List<User> selectList = sqlSession.selectList("getUserByAddress", string);
		sqlSession.close();
		return selectList;
	}


	@Override
	public void deleteUser(int i) {
		sqlSession.delete("deleteUser", i);
		sqlSession.commit();
		sqlSession.close();
	}

	
	
	

}
